<template>
    <h2>管理员投资列表</h2>
   
    理财名称
    <input type="text" v-model="state.name" />
    <input type="button" value="查询"  @click="show" >

    <table class="table table-bordered">
        <tr>
            <td>投资ID</td>
            <td>投资项目名称</td>
            <td>总额度</td>
            <td>已投金额</td>
            <td>剩余额度</td>
            <td>投资次数</td>
            <td>操作</td>
        </tr>
        <tr v-for="item in list">
            
            <td>{{ item.I_Id }}</td>
            <td>{{ item.I_Name }}</td>
            <td>{{ item.I_Sum }}</td>
            <td>{{ item.I_Money }}</td>
            <td>{{ item.I_All }}</td>
            <td>{{ item.I_Num }}</td>
            <td><input type="button" value="查看用户投资明细" @click="invest(item.I_Id)"></td>
           
        </tr>
    </table>
  
    <input type="button" value="首页" @click="page('a')" >
    <input type="button" value="上一页" @click="page('c')" >
    <input type="button" value="下一页" @click="page('d')" >
    <input type="button" value="尾页" @click="page('b')" >
   
</template>

<script setup lang="ts">
import {ref, reactive, onMounted,toRefs} from 'vue'
import {useRouter,useRoute} from 'vue-router'
import axios from 'axios';
const router=useRouter();
const route=useRoute();
const data:any=reactive({
    state:{
        name:"",PageIndex:1, PageSize:2
    },
    sum:'',
    ListCount:'',
    PageCount:'',
    list:[],
    llist:[]
})
let {state,list,ListCount,PageCount,llist,sum} =toRefs(data);
onMounted(()=>{
  show();

})
//首页 上一页 下一页 尾页
const page=(val:any)=>{
    if(val=='a')
    {
        if(state.value.PageIndex==1){
            alert('已经是首页了');
            return;
       }
       state.value.PageIndex=1;
    }
   else if(val=='b')
    {
        if(state.value.PageIndex==PageCount.value){
            alert('已经是尾页了');
            return;
       }
       state.value.PageIndex=PageCount.value;
    }
    else if(val=='c')
    {
        if(state.value.PageIndex==1){
            alert('已经是首页了');
            return;
       }
       state.value.PageIndex--
    }
    else if(val=='d')
    {
        if(state.value.PageIndex==PageCount.value){
            alert('已经是尾页了');
            return;
       }
       state.value.PageIndex++;
    }
    show();
}
//8.	管理员-投资列表分页展示
const show=()=>{
    axios({
        url:"/api/Invest/GetInvestShow",
        method:'get',
        params:state.value

    })
    .then(res=>{
        console.log(res);
        list.value=res.data.Plist;
        ListCount.value=res.data.ListCount;
        PageCount.value=res.data.PageCount;
    })
}

const invest=(id:any)=>{
    router.push({
        path:'/adminInvest',
        query:{
            id:id
        }
    })
}
</script>


<style>


</style>